package com.neuedu.dao.impl;

import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.List;

import com.neuedu.dao.IGoodsDetailDAO;
import com.neuedu.entity.GoodsDetail;
import com.neuedu.sql.QueryUpdate;
import com.neuedu.sql.ResultSetObject;

public class GoodsDetailDAOImp implements IGoodsDetailDAO {

	@Override
	public GoodsDetail selectByGNum(String gnum) {
		String sql="select * from t_goodsdetail where gnum=?";
		List<GoodsDetail> detail=QueryUpdate.query(new ResultSetObject<GoodsDetail>() {

			@Override
			public GoodsDetail getObject(ResultSet rs) throws SQLException {
				GoodsDetail d=new GoodsDetail();
				d.setDid(rs.getInt("did"));
				d.setGnum(rs.getString("gnum"));
				d.setDaddress(rs.getString("daddress"));
				d.setDflag(rs.getInt("dflag"));
				d.setDproductdate(rs.getTimestamp("dproductdate"));
				d.setDlife(rs.getInt("dlife"));
				d.setDimg(rs.getString("dimg"));
				d.setCreatetime(rs.getTimestamp("createtime"));
				d.setUpdatetime(rs.getTimestamp("updatetime"));
				return d;
			}
		}, sql, gnum);
		if(detail==null) {
			return null;
		}
		return detail.get(0);
	}

}
